import { Default_Retry_Count } from "./LogicConstant";

export function generateLoopMap(value) {
    let ret = {};
    for(let item of value||[]) {
        ret[item.loopNumber] = Object.assign({}, item);
    }
    
    return ret;
}

export function generateInitDefaultLoops() {
    let ret = [];
    for(let i = 1; i <= 6 ; i++) {
        ret.push({
                "loopName": "回路" + i,
                "loopNumber": i,
                "loopStartPortal": "",
                "loopEndPortal": "",
                "loopBrightness": 100,
                "loopStrategyId": 0,
                "loopStrategyName": ""
            });
    }
    for(let i = 101; i <= 106 ; i++) {
        ret.push({
                "loopName": "回路" + (i),
                "loopNumber": i,
                "loopStartPortal": "",
                "loopEndPortal": "",
                "loopBrightness": 100,
                "loopStrategyId": 0,
                "loopStrategyName": ""
            });
    }
    return ret;
}

export function generateGateInitValue(online, loops) {
    let ret = {onlineStatus: online, loop:{}, valid: {}};
    for(let loop of loops) {
        ret.loop[loop.loopNumber] = {
            "loopCurrentValue": 100,
            "vol": 0,
            "current": 0,
            "power": 0,
            "leak": 0,
            "color": 0,
            "state": 1
        }
    }
    return ret;
}

export function generateLoopSetLight(loops){
    let ret = {};
    for(let loop of loops) {
        ret[loop.loopNumber] = {
                "light": -1,
                "loopNumber": loop.loopNumber,
                "retry": Default_Retry_Count
            }
    }
    return ret;
}

export const fixRemoteIp = "ceshi.tengits.com";
export const fixMasterIp = "192.168.50.157";